from rest_framework import serializers
from six_it.models import Label, Question


class LabelListSerializer(serializers.ModelSerializer):
    '''标签序列化器'''
    class Meta:
        model = Label
        fields = ('id', 'label_name')


class AttentionLabelListSerializer(serializers.ModelSerializer):
    '''标签序列化器'''
    class Meta:
        model = Label
        fields = ('id', 'label_name')


class LatestAnswerQuestionsSerializer(serializers.ModelSerializer):
    '''回答数较多序列化器'''

    labels = serializers.StringRelatedField(read_only=True, many=True)
    user = serializers.StringRelatedField(read_only=True)

    class Meta:
        model = Question
        fields = ('id', 'createtime', 'labels', 'reply', 'replyname', 'replytime', 'title',
                  'unuseful_count', 'useful_count', 'user', 'visits')



class HotAnswerQuestionsSerializer(serializers.ModelSerializer):
    '''最新回答序列化器'''

    labels = serializers.StringRelatedField(read_only=True, many=True)
    user = serializers.StringRelatedField(read_only=True)



    class Meta:
        model = Question
        fields = ('id', 'createtime', 'labels', 'reply', 'replyname', 'replytime', 'title',
                  'unuseful_count', 'useful_count', 'user', 'visits')



class WaitAnswerQuestionsSerializer(serializers.ModelSerializer):
    '''未被回答序列化器'''

    labels = serializers.StringRelatedField(read_only=True, many=True)
    user = serializers.StringRelatedField(read_only=True)

    class Meta:
        model = Question
        fields = ('id', 'createtime', 'labels', 'reply', 'replyname', 'replytime', 'title',
                  'unuseful_count', 'useful_count', 'user', 'visits')




